//
//  BuyTopImageCell.m
//  MFTaobao
//
//  Created by Adiljan on 2016/10/21.
//  Copyright © 2016年 Adiljan. All rights reserved.
//

#import "BuyTopImageCell.h"



#define screenH [UIScreen mainScreen].bounds.size.height
#define screenW [UIScreen mainScreen].bounds.size.width

@implementation BuyTopImageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    _arrM = [NSMutableArray array];
    // Initialization code
//    NSString *img1 = @"https://raw.githubusercontent.com/augsun/Resources/master/JXRollView/101749.320.jpg";
//    NSString *img2 = @"https://raw.githubusercontent.com/augsun/Resources/master/JXRollView/107500.320.jpg";
//    NSString *img3 = @"https://raw.githubusercontent.com/augsun/Resources/master/JXRollView/108389.320.jpg";
    NSString *img1 = @"ad.png";
    NSString *img2 = @"ae.png";
    NSString *img3 = @"af.png";
    NSString *img4 = @"ac";
    arrUrls = [NSArray arrayWithObjects:img1,img2,img3,img4, nil];
    
    
    [self lunbo];
}

+ (instancetype)view
{
    return [[[NSBundle mainBundle] loadNibNamed:@"BuyTopImageCell" owner:nil options:nil] firstObject];
}

// 图片轮播
-(void)lunbo{
    
    self.rollViewColor = [[JXRollView alloc] initWithFrame:CGRectMake(0, 0, screenW, 277)];
    [self addSubview:self.rollViewColor];
    self.rollViewColor.pageIndicatorColor = [UIColor lightGrayColor];
    self.rollViewColor.currentPageIndicatorColor = [UIColor redColor];
    self.rollViewColor.delegate = self;
    self.rollViewColor.autoRolling = NO;
    [self.rollViewColor reloadData];
    

}
#pragma mark <JXRollViewDelegate>
- (NSInteger)numberOfItemsInRollView:(JXRollView *)rollView {
    return arrUrls.count;
}

- (void)rollView:(JXRollView *)rollView setImageForImageView:(UIImageView *const)imageView atIndex:(NSInteger)index {
////     Recommend use [[SDWebImageManager sharedManager] downloadImageWithURL:options:progress:completed:] method to set image.
////     推荐使用 [[SDWebImageManager sharedManager] downloadImageWithURL:options:progress:completed:] 方法设置图片.
//    
//    [[SDWebImageManager sharedManager] downloadImageWithURL:arrUrls[index] options:SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
//        imageView.image = image;
//        [_arrM addObject:image];
//    }];
    
    imageView.image = [UIImage imageNamed:arrUrls[index]];
//    self.imgView = imageView;
}

- (void)rollView:(JXRollView *)rollView didTapItemAtIndex:(NSInteger)index {
    NSLog(@"Tap the index %ld", index);
    if (_ClickImageBigBlock) {
        _ClickImageBigBlock(index);
    }
    
//    UIView *vu = [[UIView alloc]initWithFrame:self.superview.frame];
//    vu.backgroundColor = [UIColor redColor];
//    [self.superview addSubview:vu];
    
}

@end
